package cl.interpreter.statements;

import cl.interpreter.DuplicateVariableException;
import cl.interpreter.Environment;
import cl.interpreter.IncorrectTypeException;
import cl.interpreter.RuntimeStack;
import cl.interpreter.Statement;
import cl.interpreter.UnknownTypeException;
import cl.interpreter.Variable;

public class Declaration implements Statement {
    
    private Variable variable;
    
    public Declaration(String name, String type, Object value) throws UnknownTypeException, IncorrectTypeException {
        variable = new Variable(name, value, type);
    }



    @Override
    public void execute(RuntimeStack stack, Environment environment) throws DuplicateVariableException {
        environment.addVariable(variable);
        stack.addVariable(variable);
    }
}
